<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="operlog-form">
					<div class="select-list">
						<ul>
							<li>
								<label>名称  </label> <input type="text" name="condition[moduleName|like]"/>
							</li>
							<li>
								<label>链接  </label> <input type="text" name="condition[modulePath|like]"/>
							</li>
							<li>
								状态：<select name="condition[hasStatus]">
									<option value="">请选择</option>
									<option th:each="item:${@pageHandle.direcitoryList('has_status')}" th:value="${item.codeValue}"  th:text="${item.codeName}" >所有</option>
								</select>
							</li>
							<li>
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <!-- 
	            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()">
		            <i class="far fa-trash-alt"></i> 删除
		        </a>
		        <a class="btn btn-danger" onclick="$.operate.clean()">
	                <i class="fa fa-trash"></i> 清空
	            </a>
	            -->
	            <a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	
	<footer th:replace="dashboard/footer :: footer"></footer>

	<script>
		var detailFlag = "";
		var editFlag = "";
		var removeFlag = "";
		var resetPwdFlag = "";

		var prefix = ctx + "monitor/operlog";

		$(function() {
		    var options = {
		        url: ctx+"portal/desktop/web/module/datatables" ,
		        createUrl: ctx + 'portal/desktop/web/module/add' ,
		        updateUrl: ctx+"portal/desktop/web/module/modify?id={id}" ,
		        statusUrl: ctx+"portal/desktop/web/module/changeStatus?id={id}" , 
		        cleanUrl: prefix + "/clean",
		        detailUrl: ctx+"portal/desktop/web/module/detail?id={id}",
		        removeUrl: ctx+"portal/desktop/web/module/delete" ,
		        exportUrl: ctx+"portal/desktop/web/module/exportExcel" ,
		        sortName: "operTime",
		        uniqueId:"id" ,
		        sortOrder: "desc",
		        modalName: "",
		        escape: true,
		        showPageGo: true,
		        rememberSelected: true,
		        columns: [{field: 'state',checkbox: true },
		        	
			        {field: 'moduleLogo', title: '图标' , align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                actions.push('<i class="'+value+'" aria-hidden="true">');
			                return actions.join('');
			          }
			        },
			        {field: 'moduleName', title: '名称'},
			        {field: 'modulePath', title: '链接' , align: 'left' , formatter: function(value, row, index) {
				        	if(value.length > 50){
								 return value.substring(0 , 50) ; 
							} 
						  	return value ; 
		          		}
			        },
			        {field: 'openTargetLabel', title: '打开目标'},
			        {field: 'moduleDesign', title: '规划', align: 'center',  formatter: function(value, row, index) {
							var actions = [];
							if(value === '1'){
								actions.push('<a href="javascript:void()" onclick="designStatus(\'' + row.id + '\')">运作</a>');
							}else if(value === '0'){
								actions.push('<a href="javascript:void()" style="color:red" onclick="designStatus(\'' + row.id + '\')">规划</a>');
							}
							return actions.join('');
		          		}
			        },
			        {field: 'moduleParentIdLabel', title: '父类'},
			        {field: 'hasStatusLabel', title: '状态', align: 'center',  formatter:function(value,row,index){ return $.table.status(value , row);}},
			        // {field: 'menusId', title: '所属菜单', sortable: true},
			        {field: 'id' , title: '操作',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                
			                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="far fa-trash-alt"></i>删除</a> ');

			                return actions.join('');
			          }
			     }]
		    };
		    $.table.init(options);
		});
		
		function designStatus(_id){
			var changeDesignUrl = ctx+"portal/desktop/web/module/designStatus?id="+_id ; 
			$.operate.submit(changeDesignUrl, "get", "json", "" );	
		}
		
		function searchPre() {
		    var data = {};
		    data.businessTypes = $.common.join($('#businessTypes').selectpicker('val'));
		    $.table.search('operlog-form', data);
		}
		
		function resetPre() {
			$.form.reset();
			$("#businessTypes").selectpicker('refresh');
		}
		
		// 构建菜单
		function buildMenus(_id) {
			var options = {
				title : '菜单管理',
				url : ctx + 'portal/desktop/web/menus/menus?applicationId=' + _id,
				btn : false
			};
			$.modal.openOptions(options);
		}
	</script>
</body>
</html>